<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>v-model原理</title>
    <script src="../lib/vue_v2.6.14.js"></script>
  </head>
  <body>
    <div id="app">
      <!-- 原理：写法一 -->
      <!-- <input type="text" :value="inputVal" @input="inputValChange" /> -->

      <!-- 原理：写法二 -->
      <input type="text" :value="inputVal" @input="inputVal = $event.target.value" />
      <h3>input值：{{ inputVal }}</h3>
    </div>

    <script>
      const vm = new Vue({
        el: '#app',
        data: {
          inputVal: 'hello v-model'
        },
        methods: {
          inputValChange(e) {
            this.inputVal = e.target.value
          }
        }
      })
    </script>
  </body>
</html>
